//
import { http } from '@/utils/http'
import {
  AddressCustom,
  ResponsePage,
  AddAddressData,
  PersonResponse,
  PersonInfoUpdate,
  CouponsResponse,
  EditAddressData,
  CouponDetail,
} from './my.type'

/** 获取首页数据 */
export const getMyPage = () => {
  return http.post<ResponsePage>('mine', {})
}
// 添加地址 /user/addressAdd
export const addAddress = (data: AddAddressData) => {
  return http.post('user/addressAdd', data)
}
// 修改地址 /user/addressEdit
export const updateAddress = (data: EditAddressData) => {
  return http.post('user/addressEdit', data)
}
// 获取地址列表 /user/address
export const getAddressList = () => {
  return http.post<AddressCustom>('user/address')
}
// 获取、删除、修改地址

// 获取用户信息 /user/info
export const getUserInfo = () => {
  return http.post<PersonResponse>('user/info', {})
}
// 修改用户信息 /user/info
export const updateUserInfo = (data: PersonInfoUpdate) => {
  return http.post('user/info', data)
}
// 我的优惠卷 /user/coupons
export const getMyCoupons = (data: CouponDetail) => {
  return http.post<CouponsResponse>('user/coupons', data)
}
// 地址选择器 /user/area
export const getAreaList = () => {
  return http.post('user/area', {})
}
// 获取收藏 /user/collects
export const getCollects = () => {
  return http.post('user/collects', {})
}
// 分享赚 /activity/share
export const shareGetMoney = () => {
  return http.post('activity/share', {})
}
// 分享赚粉丝 /activity/shareFans
export const shareGetFans = () => {
  return http.post('activity/shareFans', {})
}
// 分享赚订单 /activity/shareOrders
export const shareGetOrders = () => {
  return http.post('activity/shareOrders', {})
}
// 修改用户信息 /user/edit
export const editUser = (data: PersonInfoUpdate) => {
  return http.post('user/edit', data)
}
// 获取app配置 /app-config
export const getAppConfig = () => {
  return http.post('app-config', {})
}
// 获取短信验证码 /sms
export const getsms = (mobile: string) => {
  return http.post('sms', { mobile })
}
// 获取天琴币流水 /user/bonusRecord
export const getBonusRecord = (type: -1 | 0 | 1) => {
  return http.post('user/bonusRecord', { type })
}
